package cn.xinfei.xdecision.web.interceptor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *  会话拦截器
 */
@Slf4j
@Component
public class XDecisionInterceptor extends HandlerInterceptorAdapter {
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//		String uri = request.getRequestURI();
//		String ip = RequestUtil.getClientIP(request);
//		String requestMethod = request.getMethod();
//		StringBuffer requestURL = request.getRequestURL();
//		String bizId = request.getHeader(Constants.BIZ_ID);
//		Enumeration<String> headerNames = request.getHeaderNames();
//		String scene = request.getHeader("scene");
//		if(StringUtils.isEmpty(bizId)){
//			String todayNow = LocalDateUtils.getTodayNow(DATE_SIMPLE_PATTERN);
//			long todayInc = stringRedisTemplate.opsForValue().increment(INCR + scene + todayNow);
//			bizId = SerialNumberUtils.create(scene, todayInc);
//			XDecisionContext.getContext().setDecisionId(bizId);
//		}
//		XDecisionContext.getContext().setRequestId(bizId);
		return true;
	}



}